﻿@using KhoaLuan.Resources.Product
    <div class=" row">

        <article class="col-md-9">
            <div class="nn-body">
                

                <div class="header-block">
                    <p style="padding-top: 10px; margin-left: 10px;">@Index.TatCaSanPham</p>
                </div>
                <div class="row product">
                    <div id="Carousel" class="carousel slide">
                        <div class="row product">
                            @foreach (var p in Model)
                            {
                                <div class="pro">
                                    <div class="pro-pro">
                                        <a class="pro-img" href="/Product/Detail/@p.Id">
                                            <img class="image" src="~/images/products/@p.Image" />
                                        </a>
                                        <a href="/Product/Detail/@p.Id" class="pro-name">@p.Name</a>
                                        <p class="pro-price">@Html.FormatValue(p.UnitPrice, "{0:C}")</p>
                                       
                                        <a class="add-to-cart" href="/Cart/Add/@p.Id">

                                            <img src="~/images/icons/Add%20to%20basket.png" />
                                        </a>
                                        <div class="icon">
                                            @if (p.Latest)
                                            {
                                                
                                                <img src="~/images/icons/new.png" />
                                            }
                                            else if (p.Special)
                                            {
                                               
                                                 <img src="~/images/icons/hot.png" />
                                            }
                                            else if (p.Discount > 0)
                                            {
                                                <img src="~/images/promo_icon.gif" />
                                            }
                                        </div>
                                    </div>
                                </div>
                            }

                        </div>
                    </div>
                </div>
                          
          
            
            
            
            </div>
        </article>

        <aside class="col-md-3">
            <br />
            <!--Cart Info-->
            <div class="panel panel-default nn-cart">
                @Html.Partial("_TimKiemNhanh")
            </div>
            <!--/Cart Info-->
            <!--Chủng loại-->
            <div class="panel panel-default">
                @Html.Action("CategoryMenu", "Product")
            </div>
            <!--/Chủng loại-->
            <!--Nhà cung cấp-->
            <div class="panel panel-default">

                @Html.Action("NhaCungCapMenu", "Product")
            </div>
            <!--/Nhà cung cấp-->
            <!--Hàng đặc biệt-->
            <div class="panel panel-default">
                @Html.Partial("_HangDacBiet")
            </div>
            <!--/Hàng đặc biệt-->
        </aside>
    </div>
   
@section scripts{
    <script src="~/jquery-ui/jquery-ui.min.js"></script>
    <link href="~/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <style id="cart-fly"></style>
    <script>
        $(function () {
            $("a.add-to-cart").click(function () {
                var anh = $(this).parents("div.pro").find(".image");
                var css = ".cart-fly {background: url(" + anh.attr("src") + ");background-size:100% 100%;}";
                $("#cart-fly").html(css);

                var options = { to: "#cart-image", className: "cart-fly" }
               
                anh.effect("transfer", options, 1000);

                href = $(this).attr("href");
                $.ajax({
                    url: href,
                    data: {},
                    success: function (response) {
                        $("#cart-count").html(response.Count + " măt hàng");
                        $("#cart-amount").html(response.Amount + "VND ");
                    }
                });
                return false;// hủy chức năng của liên kết
            });
        });
    </script>
}